package com.richman.hg;


import java.awt.Color;
import java.awt.EventQueue;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.Date;
import java.util.Stack;

import org.apache.http.Header;
import org.apache.http.HttpEntity;
import org.apache.http.HttpHost;
import org.apache.http.NameValuePair;
import org.apache.http.ParseException;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.config.CookieSpecs;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import org.eclipse.swt.browser.Browser;
import org.apache.http.entity.StringEntity;

import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;

import org.json.*;



import java.util.Vector;
import java.util.Comparator;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
//
//import javax.xml.parsers.DocumentBuilder;  
//import javax.xml.parsers.DocumentBuilderFactory;  
//  
//
//
//import org.w3c.dom.Document;  
//import org.w3c.dom.Element;  
//import org.w3c.dom.NodeList;

import com.richman.controller.DecreaseRatioClient;
import com.richman.ps38.entity.BetAdyData;
import com.richman.ps38.entity.HGEvent;
import com.richman.utils.Common;
import com.richman.utils.SoundThread;
import com.richman.view.BetWindow;

import org.jsoup.Jsoup;
import org.jsoup.helper.Validate;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;







//import org.w3c.dom.Node;


public class HGHttpSpecial {

	CloseableHttpClient httpclient = null;
	RequestConfig requestConfig = null;
	HttpClientContext clientContext = null;
	
	
	
	int defaultTimeout = 60*1000;
	
	 {
		 
		 HttpHost proxy = new HttpHost("127.0.0.1", 1080, "http");
		 
	    requestConfig = RequestConfig.custom().setCookieSpec(CookieSpecs.STANDARD).build();
	    requestConfig = RequestConfig.copy(requestConfig).setRedirectsEnabled(false).build();//禁止重定向 ， 以便获取cookieb18
	    
	   // requestConfig = RequestConfig.copy(requestConfig).setProxy(proxy).build();//使用代理
	    
	    requestConfig = RequestConfig.copy(requestConfig).setConnectTimeout(defaultTimeout).setConnectionRequestTimeout(defaultTimeout).setSocketTimeout(defaultTimeout).build();//设置超时
	        httpclient = HttpClients.custom().setDefaultRequestConfig(requestConfig).build();
	 }
	
	 
	 
	 
	 String[] blackboxarry = {"0400AKHeWb1CT4UHcCiyOFFxUJs9WruPWg2xwTpqC7aOF/G7cVE#xxeTH9qn7gvBN1hODpQyKLUtdcy/gVjxK6YQUmuthzD1rRD5A9buc5roGxhe#J5xbAcO8rvcbfkqJhb4bZWp/5NFsh3QANolZLufCAU8wqwM/zbpaoaJowy5lsfph/T#lMlRTFuxuMBV69L9DJ0qCc4gMpergecSo06izT8HnO#s8lyWpM5YbymrVY7rLMnUY2Yy4xZkFqaUZegb#KaePAdj0dC1DOkZ9ybRxHxfYV3WeA0UYsMZmVY5fSPUN2oHNYZpt1ozpn47xUgPTMj6Y82LrlflYU9iUMb03YzV7IDBIIRtgx5t4CWwXewJB/s4Mwp5btF9#kXk6jWRn9G0Cffid9KqGO3oLohutw1/InDlj2XMuF6OiUfqPLjYdgXmjJkcl5haIlLY6FnWC1qHoGk5NgOHQJG3PEGJQEF/V33vgKI2yAfUMZ5LKFpDFK356A5kn36mAJ3ZTHu23WaFMcpDuPLLCLfgMB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AZ7wObrIPkDUNNQmTZ7suARIubHa83CDZB6X9z3t5GOE3v/P0fK0Mpi/qz28j7#e7ulr6Q2kPzVR88eWj0RX0JHstg9WGLJ44uwgvmQv7oSpR7vSRRYaqhKKhmTNPWCy4nJzQCugKVOTcKUJixNc9QoXJB6xfRWCqp0tokzUp0K#OKLn0OAhXJ9AFUmoq3MFE1OVZYIN0TiGh2ocxF8rf4jemlekKDk9nbjLKqMlA4FJr4dyXapdkDIJTQkZrrm8#sZ"
	 };	


	 String chars = "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz1234567890";


	

	private int statusCode = -1;
	
	
	
    Vector<Long> lastTenRequestTime = new Vector<Long>();
    long avgRequestTime = 0;    
    boolean bcalcRequestTime = true;
    boolean bneedChangeLine = false;
   
   
    long lastChangeLineTime = 0;
   
    String strCookies = "";
   
    int requestFailTimes = 0;
    long lastFailtime = 0;
   
    boolean isNeedRelogin = false;
   
    public boolean isInRelogin = false;
    
	 String ADDRESS = "";
	 String ACCOUNT = "";
	 String PWD = "";
	 String SECURITYCODE = "";
	 
	 String user_id = "";
	 String mtype = "3";
	 String cid = "";
	 int time_zone = 0;
	 
	 boolean bLogin = false;
	 
	 
	 String oldSiteAddress = "";
	
	 
	  Vector<String> showLeagueName = new Vector<String>();
	 
    private  ReadWriteLock lockeFinalEventsDetails = new ReentrantReadWriteLock();
    
    private  ReadWriteLock lockeSuccessTime = new ReentrantReadWriteLock();
    
    
    private  ReadWriteLock inplaydxqgameslock = new ReentrantReadWriteLock();
    
    
    public  Vector<String[]> finalEventDetailsVec = new Vector<String[]>();

    public  String successTime = "";
	 
    
    public long canLoginTime;
    public long checkOnlineTime;
    
    
    public int getStatusCode() {
   	 return statusCode;
    }
    
    public String getuser_id() {
    	return user_id;
    }
    
    // 1成功	 -1登录失败, -2维护 , -3账号异常 , -4密码不正确 , 2抓取成功, 3抓取失败
    public void updateStatusCode(int i) {

    	String accounttype  = "";
    	if(mtype.equals("1")) {
    		accounttype = "A盘	";
    	}else if(mtype.equals("2")) {
    		accounttype = "B盘";
    	}else if(mtype.equals("3")) {
    		accounttype = "C盘";
    	}else if(mtype.equals("4")) {
    		accounttype = "D盘";
    	}
    	
    	boolean printToMainwnd = false;
    	
    	if(ACCOUNT.equals(DecreaseRatioClient.betCtrMng.getinUsedAccountName())) {
    		printToMainwnd = true;
    	}
    	
    	if(i == -2) {
    		canLoginTime = System.currentTimeMillis() + 5*60*1000;
    		
    		if(printToMainwnd = true) {
    			DecreaseRatioClient.mainWnd.updateMainWndSpecialHGStatusText(0,  "网站维护中");
    		}
    		
    		
    		
    	}
    	
    	
    	if(i == 1) {
    		checkOnlineTime = System.currentTimeMillis() + 30*1000;
    		if(printToMainwnd = true) {
    			DecreaseRatioClient.mainWnd.updateMainWndSpecialHGStatusText(1, ACCOUNT +"   "+ accounttype + "在线");
    		}
    		
    		
    	}
    	
    	if(statusCode != 1) {
    		if(printToMainwnd = true) {
    			DecreaseRatioClient.mainWnd.updateMainWndSpecialHGStatusText(0, ACCOUNT +"   " + "登录中");
    		}
    		
    		
    		DecreaseRatioClient.showtext += Common.getcurrentTimeStr() + ACCOUNT + ":皇冠2登陆中...\n";
    	}
    	
    	if(statusCode != 1 && i == 1) {
    		if(printToMainwnd = true) {
    			DecreaseRatioClient.mainWnd.updateMainWndSpecialHGStatusText(1, ACCOUNT +"   "+ accounttype + "在线");
    		}
    		
    		DecreaseRatioClient.showtext += Common.getcurrentTimeStr() + ACCOUNT + ":皇冠2登录成功\n";
    	}
    	
    	
    	if(i == -1) {
    		if(printToMainwnd = true) {
    			DecreaseRatioClient.mainWnd.updateMainWndSpecialHGStatusText(0, "掉线,重新登录中");
    		}
    		
    		
    		//发出声音
    		if(SoundThread.inPlay == false){
				SoundThread st = new SoundThread();
				SoundThread.status = 2;
				st.start();
			}
    	}
    	
    	
    	if(statusCode != i) {
    		System.out.println("皇冠2HTTP状态更新" + ACCOUNT + "  update hg_statusCode from " +   Integer.toString(statusCode) + " to " + Integer.toString(i));
    	}
    	
    	
    	
    	DecreaseRatioClient.mainWnd.updateHGAccountStatus(ACCOUNT, statusCode);
    	
    	
   	 statusCode = i;
    
    }
    
    
    public long getCanLoginTime() {
   	 return canLoginTime;
    }
    
    public long getCheckOnlineTime() {
    	return checkOnlineTime;
    }
    
    
	public  void initShowLeagueName(){
		showLeagueName.add("德国 - 德甲");
		showLeagueName.add("欧足联 - 冠军联赛");
		showLeagueName.add("西班牙 - 西甲");
		showLeagueName.add("意大利 - 甲级联赛");
		showLeagueName.add("法国 - 甲级联赛");
		showLeagueName.add("英格兰 - 超级联赛");
		showLeagueName.add("欧足联 - 欧罗巴联赛");
	}
	
	
	public void clearuser_id(){
		user_id = "";
	}
	
	public void setAddress(String address){
		ADDRESS = address;
	}

	public   boolean isInShowLeagueName(String str){
		boolean in = false;
		
		for(int i = 0; i < showLeagueName.size(); i++){
			if(showLeagueName.elementAt(i).contains(str)){
				in = true;
				break;
			}
		}
		
		return in;
	}
    
    
	public  void setGrabStext(String str){

		SimpleDateFormat df = new SimpleDateFormat("MM-dd HH:mm:ss");// 设置日期格式
		
		String timeStr = df.format(System.currentTimeMillis());

		//gamedetailswnd.setStateText(timeStr + ":" + str);

	}
	
	public  void setGrabColor(Color cr){
		
		//gamedetailswnd.setStateColor(cr);
	
	}
	
	
    

	
	
	
    
    
    public  void copyTofinalEventsDetails(){
    	
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm");// 设置日期格式
		
		
		long currentTimeL = System.currentTimeMillis();
    	
		String currentTime = df.format(currentTimeL);
    	
    	lockeFinalEventsDetails.writeLock().lock();
    	
    	if(finalEventDetailsVec.size() != 0){
    		finalEventDetailsVec.clear();
    	}
    	
//    	for(int i = 0; i < eventDetailsVec.size(); i++ ){
//    		finalEventDetailsVec.add(eventDetailsVec.elementAt(i).clone());
//    	}

    	
    	lockeFinalEventsDetails.writeLock().unlock();
    	
    	lockeSuccessTime.writeLock().lock();
    	successTime = currentTime + " 成功";
    	lockeSuccessTime.writeLock().unlock();
    }
    
    
    public  Vector<String[]> getFinalEventsDetails(){
    	Vector<String[]> vec = new Vector<String[]>();
    	lockeFinalEventsDetails.readLock().lock();
    	
    	for(int i = 0; i < finalEventDetailsVec.size(); i++){
    		vec.add(finalEventDetailsVec.elementAt(i).clone());
    	}
    	
    	//vec = (Vector<String[]>)finalEventDetailsVec.clone();
    	lockeFinalEventsDetails.readLock().unlock();
    	return vec;
    }
    
    
    public  String getSuccessTime(){
    	String successTimetmp = "";
    	lockeSuccessTime.readLock().lock();
    	successTimetmp = successTime;
    	lockeSuccessTime.readLock().unlock();
    	return successTimetmp;
    }

	 
	 

	
	
	
	
	public String getAccount(){
		return ACCOUNT;
	}
    
    
	public boolean islogin(){
		return bLogin;
	}	 
	
	public void setIslogin(boolean b){
		bLogin = b;
	}
	
	public  void setLoginParams(String address, String account, String pwd){
		ADDRESS = address;
		ACCOUNT = account;
		PWD = pwd;
	}
	
	

    public int login(){// 1成功	 -1登录失败, -2维护 , -3账号异常, -4密码不正确
    	
    	try{
    		
    		
    		
        	String loginLine = ADDRESS;
        	
        	String res = doGet(loginLine, "", "");
        	
        	if(res.contains("è")){
        		res = new  String(res.getBytes("ISO-8859-1"), "utf-8");
        	}
        	
        	
        	System.out.println("address" + ADDRESS + "        account:" + ACCOUNT + "    pwd:" + PWD);
        	
        	
        	if(res != null && res.contains("Welcome")){
        		res = doGet(loginLine + "app/member/", "", "");
        		
        		if(res.contains("è")){
            		res = new  String(res.getBytes("ISO-8859-1"), "utf-8");
            	}
        		
        		
        		if(res.contains("chgURL_new_domain")){
        			
        			
//        			int pstmp1 = res.indexOf("chgURL_domain");
//        			pstmp1 = res.indexOf("'", pstmp1) + 1;
//        			int petmp1 = res.indexOf("'",pstmp1);
//        			
//        			oldSiteAddress = "http://" + res.substring(pstmp1, petmp1) + "/";
        			
        			
        			
        			res = doGet(ADDRESS + "iovation/vindex.php", "", "");
        			
    	        	if(res.contains("è")){
                		res = new  String(res.getBytes("ISO-8859-1"), "utf-8");
                	}
        			
    		        List<NameValuePair> params = new ArrayList<NameValuePair>();		  
    		        
    		        params.add(new BasicNameValuePair("username", ACCOUNT));
    		        params.add(new BasicNameValuePair("passwords", PWD));
    		        params.add(new BasicNameValuePair("auto", "CFADCB"));
    		        params.add(new BasicNameValuePair("langx", "zh-cn"));

    		        int arrayindex =(int)(Math.random()*4);
    		        String blackbox = blackboxarry[arrayindex];
    		        StringBuilder strBuilder = new StringBuilder(blackbox);
    		        for(int i = 26; i < 34; i++){
    		        	strBuilder.setCharAt(i, chars.charAt((int)(Math.random()*62)));
    		        }
    		        blackbox = strBuilder.toString();
    		        
    		        params.add(new BasicNameValuePair("blackbox", blackbox));
    		        res = doPost(ADDRESS + "app/member/new_login.php", params, "");
    		        
    	        	if(res.contains("è")){
                		res = new  String(res.getBytes("ISO-8859-1"), "utf-8");
                	}
    		        
    		        if(null != res && res.contains("200|100")){
    		        	
    		        	int ps = res.indexOf("||") + 2;
    		        	int pe = res.indexOf("|",ps);
    		        	
    		        	String loginfo[] = res.split("\\|");
    		        	
    		        	user_id = loginfo[3];
    		        	
    		        	mtype = loginfo[4];
    		        	
    		        	//user_id = res.substring(ps, pe);
    		        	
    		        	
    		        	updateStatusCode(1);
    		        	
    		        	return 1;
    		        	
    		        	

    		        }
    		        
    		        
        		}
        		
        		
        	}
        	
        	
        	
        	
        	
        	if(res.contains("System Maintenance")|| res.contains("maintain_time")|| res.contains("请稍后再尝试登入")){
        		
        		updateStatusCode(-2);
        		
        		return -2;
        	}
        	
        	if(res.contains("请联系您的上线")){
        		
        		updateStatusCode(-3);
        		
        		return -3;
        	}
        	
        	if(res.contains("密码不正确")) {
        		updateStatusCode(-4);
        		
        		return -4;
        	}
        	
        	System.out.println("登录失败:");
        	
        	System.out.println(res);
    		
    	}catch(Exception e){
    		e.printStackTrace();
    		
    	}
    	
    	updateStatusCode(-1);
    	
    	return -1;
    }
    


    public String getmtype() {
    	return mtype;
    }

	
    public  CloseableHttpResponse  execute(HttpUriRequest request) throws IOException, ClientProtocolException{
    	
    	long time1 = System.currentTimeMillis();
    	long time2 = System.currentTimeMillis();
    	
    	CloseableHttpResponse response;
    	
    	
    	SimpleDateFormat dfsec = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    	
    	
    	try{
    		Thread.sleep(100);
    		//Thread.sleep(1200);
    	}catch(Exception e){
    		e.printStackTrace();
    	}
    	
    	
    	
    	
    	//System.out.println("excecute time:" + dfsec.format(time1));
    	
    	
    	try{
    		response = httpclient.execute(request);    		
    		time2 = System.currentTimeMillis();    		
    		calcRequestAveTime(time2 - time1);
    		
    	}catch(Exception e){
    		
    		time2 = System.currentTimeMillis();
    		calcRequestAveTime(time2 - time1);
    		
    		throw e;
    	}
    	

    	
    	return response;
    	
    }
    
    
    public String doGet(String url, String cookies, String referUrl) {
    	
        try {  
            // 创建httpget.    
            HttpGet httpget = new HttpGet(url);
            
            if(cookies != "") {
            	httpget.addHeader("Cookie",cookies);
            }
            httpget.addHeader("Accept-Encoding","Accept-Encoding: gzip, deflate, sdch");
            httpget.addHeader("Accept-Language","Accept-Language: zh-CN,zh;q=0.8");
            httpget.addHeader("Connection","keep-alive");
            httpget.addHeader("Upgrade-Insecure-Requests","1");
            httpget.addHeader("Accept","text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
            //
            
            if(referUrl != "")
            {
            	httpget.addHeader("Referer",referUrl);
            	
            }
            
            httpget.addHeader("User-Agent","Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.79 Safari/537.36");           
           // System.out.println("executing request " + httpget.getURI()); 
           
            //设置超时
            
//            HttpHost proxy = new HttpHost("127.0.0.1", 1080, "http");
//            
//            RequestConfig requestConfigtmp = RequestConfig.custom().setSocketTimeout(defaultTimeout).setConnectTimeout(defaultTimeout).build();
//            requestConfigtmp= RequestConfig.copy(requestConfigtmp).setProxy(proxy).build();
//            httpget.setConfig(requestConfigtmp);
            
            // 执行get请求.    
            CloseableHttpResponse response = execute(httpget); 
            
            String statusLine = response.getStatusLine().toString();   
            if(statusLine.indexOf("200 OK") == -1) {
         	  // System.out.println(statusLine); 
            }
            
            try{
            	setCookie(response);  	
            	//System.out.println("设置cookie:" + strCookies);
            	
            	if(response.getStatusLine().toString().indexOf("302 Found") > 0) {
             	   return response.getFirstHeader("Location").getValue();
                }
                HttpEntity entity = response.getEntity(); 
                
                String res = EntityUtils.toString(entity);
                
                if(res != null && res.length() > 0 ){     
                	//System.out.println(res);
                	
                	if(res.contains("logout_warn")) {
                		updateStatusCode(-1);
                	}
                	
                    return res;
                }
            }finally{
                httpget.releaseConnection();
                response.close();
            }
            

            

        } catch (ClientProtocolException e) {  
            e.printStackTrace(); 
        } catch (ParseException e) {  
            e.printStackTrace(); 
        } catch (IOException e) {  
            e.printStackTrace(); 
        } catch (Exception e){
        	e.printStackTrace();
        }
        
        return null;
    }
    
    
    
    /**以utf-8形式读取*/
    public String doPost(String url,List<NameValuePair> formparams, String cookies) {
        return doPost(url, formparams,"UTF-8", cookies);
    }

    public String doPost(String url,List<NameValuePair> formparams,String charset, String cookies) {


     // 创建httppost   
    	
    	try {
    	
        HttpPost httppost = new HttpPost(url); 
        
/*        if(url.contains("get_today_ft_league_wager.php")){
        	httppost.addHeader("Cookie", strCookies);
        }*/
        
        //httppost.addHeader("Cookie", cookies);
        //httppost.addHeader("Accept-Encoding","Accept-Encoding: gzip, deflate, sdch");
        //httppost.addHeader("x-requested-with","XMLHttpRequest");
        httppost.addHeader("Accept-Language","Accept-Language: zh-CN");
        httppost.addHeader("Accept","application/json, text/javascript, */*; q=0.01");
        httppost.addHeader("Accept-Encoding","gzip, deflate");
        httppost.addHeader("Connection","keep-alive");
        httppost.addHeader("Cache-Control","max-age=0");
        httppost.addHeader("User-Agent","Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.79 Safari/537.36");    


        UrlEncodedFormEntity uefEntity;
        
            uefEntity = new UrlEncodedFormEntity(formparams, charset);
            httppost.setEntity(uefEntity);
            
            
            
            
//            HttpHost proxy = new HttpHost("127.0.0.1", 1080, "http");
//            
//
//            
//            
//            
//            RequestConfig requestConfigtmp = RequestConfig.custom().setSocketTimeout(defaultTimeout).setConnectTimeout(defaultTimeout).build();
//            requestConfigtmp= RequestConfig.copy(requestConfigtmp).setProxy(proxy).build();
//            httppost.setConfig(requestConfigtmp);
            
            CloseableHttpResponse response = execute(httppost);
            try {
                // 打印响应状态    
            	setCookie(response);
            	//System.out.println("设置cookie:" + strCookies);
            	if(response.getStatusLine().toString().indexOf("302 Found") > 0) {
            		String location = response.getFirstHeader("Location").getValue();
            		//System.out.println(response.getStatusLine());
            		
            		
            		
            		if(location != null) {
            			return location;
            		}
            	}
            	
            	
            	
            	//Header headers[] = response.getHeaders("Content-Type");
            	
            	
                HttpEntity entity = response.getEntity(); 
                
                String res = "";
                
                if(url.contains("get_today_ft_league_wager.php") || url.contains("app/ft/get_today_ft_allbets_wager.php")){            		
                	res = new  String(EntityUtils.toString(entity).getBytes("ISO-8859-1"), "UTF-8");
                }else{
                	res = EntityUtils.toString(entity);
                }
                
                
                if(res != null && res.length() > 0 ){   

                	if(res.contains("logout_warn")) {
                		updateStatusCode(-1);
                	}
                	
                	//System.out.println(res);
                    return res;
                }
            	
            	

            } finally {  
            	httppost.releaseConnection();
                response.close(); 
            }  
        } catch (ClientProtocolException e) {  
            e.printStackTrace(); 
        } catch (UnsupportedEncodingException e1) {  
            e1.printStackTrace(); 
        } catch (IOException e) {  
            e.printStackTrace(); 
     
        } catch(Exception e){
     	   e.printStackTrace();
        } 
        return null;
    }
    
    
    
	public String setCookie(CloseableHttpResponse httpResponse)
	{
		//strCookies = "";
		//System.out.println("----setCookieStore");
		Header headers[] = httpResponse.getHeaders("Set-Cookie");
		if (headers == null || headers.length==0)
		{
			//System.out.println("----there are no cookies");
			return null;
		}

		String cookie = "";
		for (int i = 0; i < headers.length; i++) {
			cookie += headers[i].getValue();
			if(i != headers.length-1)
			{
				cookie += ";";
			}
		}
		String cookies[] = cookie.split(";");
		
		for (String c : cookies)
		{
			if(c.indexOf("path=") != -1 || c.indexOf("expires=") != -1 || c.indexOf("domain=") != -1 || c.indexOf("HttpOnly") != -1)
				continue;
			strCookies += c;
			strCookies += ";";
		}
		//System.out.println("----setCookieStore success");

		return strCookies;
	}
    
    
    public synchronized void calcRequestAveTime(long requestTime){
        
    	if(bcalcRequestTime == true){
    		
        	//requestCount++;
        	
    		long totalReqeustTime = 0;
    		
        	lastTenRequestTime.add(requestTime);
        	
        	while(lastTenRequestTime.size() >10){
        		lastTenRequestTime.remove(0);
        	}
        	
        	
        	if(lastTenRequestTime.size() == 10){
            	for(int i = 0; i < lastTenRequestTime.size(); i++){
            		totalReqeustTime += lastTenRequestTime.elementAt(i);
            	}
            	avgRequestTime = totalReqeustTime/lastTenRequestTime.size();
            	
            	
            	//System.out.printf("[迪斯尼会员]平均请求时间:%d\n", avgRequestTime);
            	
            	
            	long currentTime = System.currentTimeMillis();
            	
            	long passTime = currentTime - lastChangeLineTime;
            	
            	if(avgRequestTime >= 500 && passTime >= 90*1000){
            		//setisNeedChangeLine(true);
            		lastChangeLineTime = currentTime;
            	}

        	}

    	}

    		
    	
    }
    

    
    public   void addFailsTimes(){
    	
    	System.out.println("add failed times");
    	
    	long currentTime = System.currentTimeMillis();
    	
    	if(((currentTime - lastFailtime) < 40*1000) || (lastFailtime == 0)){
    		requestFailTimes++;
    		
    		lastFailtime = currentTime;
    		
    		if(requestFailTimes >= 8){    			
    			System.out.println("request fail times big than 4");    			
    			setIsNeedRelogin(true);
    			requestFailTimes = 0;
    			
    			
    			
    			
    		}
    		
    	}
    	else{
    		requestFailTimes = 1;
    		lastFailtime = currentTime;
    	}
    }
    
    
    public   void setIsNeedRelogin(boolean flag){
    	
    	System.out.println("set need relogin");
    	
    	isNeedRelogin = flag;
    	requestFailTimes = 0;
    	
    	
    	updateStatusCode(-1);
    	
    	
    }
    
    public   boolean getIsNeedRelogin(){
    	return isNeedRelogin;
    }

	public void checkIsOnline() {
		
		try {
			
//			String resultUri = "http://hga030.com/app/member/account/result/result.php?uid=" + user_id + "&langx=zh-cn&game_type=FT";
//			
//			String res = doGet(resultUri, "", "");
//			
//			if(res == null) {
//				res = doGet(resultUri, "", "");
//			}
//			
//			if(res!=null && res.contains("game_type")) {
//				updateStatusCode(1);
//			}else {
//				if(res!= null && res.contains("window.location.href")) {
//					updateStatusCode(1);
//				}else {
//					updateStatusCode(-1);
//				}
//				
//			}
			
			
			
			//http://hga030.com/app/member/reloadCredit.php?uid=8qiakegntm17590281l149442&langx=zh-cn
			
			String resultUri =  ADDRESS + "app/member/reloadCredit.php?uid=" + user_id + "&langx=zh-cn";
			
			String res = doGet(resultUri, "", "");
			
			if(res == null) {
				res = doGet(resultUri, "", "");
			}
			
			
			if(res == null) {
				return;
			}
			
			
			if(res!=null && (res.contains("人民币") || res.contains("印尼盾") )) {
				
				
				if(res.contains("è")){
	        		res = new  String(res.getBytes("ISO-8859-1"), "utf-8");
	        	}
				
				updateStatusCode(1);
				
				int ps = res.indexOf("人民币");
				
				if(ps == -1) {
					ps = res.indexOf("印尼盾");
				}
				
				ps = res.indexOf(" ", ps) + 1;
				int pe = res.indexOf("'", ps);
				
				String balance = res.substring(ps, pe).replace(",", "");
				
				DecreaseRatioClient.mainWnd.updateHGAccountBalance(ACCOUNT, balance);
				
				
			}else {
				
				
				if(res.contains("timed out")) {
					Common.logOut("hg 取余额失败，超时，不需要重新登录");
					return;
				}
				
				
				if(res!= null && res.contains("window.location.href")) {
					updateStatusCode(1);
				}else {
					updateStatusCode(-1);
				}
				
			}
			
			
			
		}catch(Exception e){
			e.printStackTrace();
			
			if(e.toString().contains("timed out")) {
				Common.logOut("hg 取余额失败，超时，不需要重新登录");
				return;
			}
			
			updateStatusCode(-1);
		}
		
	}
    
    
	
	
	
    public Vector<HGEvent> getInplaybet(){

    	try{
    		
        	String res = "";
        	
        	Vector<HGEvent> HGEvents = new Vector<HGEvent>();

            res = doGet(ADDRESS + "app/member/FT_browse/body_var.php?" + "uid=" + user_id + "&rtype=re" + "&langx=zh-cn" + "&mtype=" + mtype + "&page_no=0" + "&league_id=&hot_game="  + "&isie11=%27N%27" , "", "");
            
            
            if(res == null){
            	
            	Thread.currentThread();
				Thread.sleep(4*1000);
            	
                res = doGet(ADDRESS + "app/member/FT_browse/body_var.php?" + "uid=" + user_id + "&rtype=re" + "&langx=zh-cn" + "&mtype=" + mtype + "&page_no=0" + "&league_id=&hot_game="+ "&isie11=%27N%27"   , "", "");            	
            }
            
            if(res == null){
            	addFailsTimes();
            	return null;
            }
            
            
          //  System.out.println(res);
            
            
            if(res.contains("logout_warn")){
            	
            	System.out.println("inplay contains logout_warn");
            	
            	setIsNeedRelogin(true);
            	
            	return null;
            	
            }
            
            
            
            
            
            String previousgame = "";
            
            String currentgame = "";
            
            int priority = -1;

            
    		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");// 设置日期格式
    		
    		
    		long currentTimeL = System.currentTimeMillis();
        	
    		String currentTime = df.format(currentTimeL);
            
            
            
            if(null != res && res.contains("g([")){

            	//解析工作  第一页
            	//res = bala...
            	
            	if(res.contains("è")){
            		res = new  String(res.getBytes("ISO-8859-1"), "utf-8");
            	}
            	
            	//int ps = res.indexOf("_.gamount=");
            	int ps = res.indexOf("today_gmt");
            	ps = res.indexOf("'", ps) + 1;
            	int pe = res.indexOf("'", ps);
            	
            	String year = res.substring(ps, pe).split("-")[0];
            	
            	
            	//ps = res.indexOf(arg0)
            	
            	ps = res.indexOf("g([") + 3;
            	pe = res.indexOf(";", ps);
            	
            	
            	
            	//System.out.println(res);
            	
            	
            	SimpleDateFormat dfmin = new SimpleDateFormat("yyyy-MM-dd HH:mm");

            	
            	while(ps != -1){
            		
            		boolean bignore = false;
            		
            		String[] details = res.substring(ps, pe).split(",");
            		
            		if(details.length < 57){
            			System.out.println("fuck length small than 57");
            		}
            		
            		String eventid = details[50];
            		eventid = eventid.replace("'", "");
            		
            		
            		currentgame = eventid;
            		
//            		if(!currentgame.equals(previousgame)){
//            			priority = 1;
//            		}else{
//            			priority = priority + 1;
//            			bignore = true;
//            		}
            		

            		
             		String scoreh = details[18];
            		scoreh = scoreh.replace("'", "");
            		
            		String scorec = details[19];
            		scorec = scorec.replace("'", "");
            		
            		
            		String timer = details[48];
            		timer = timer.replace("'", "");

            		timer = timer.replace("^", " ");
            		
            		if(timer.contains("半场")) {
            			timer = "半场";
            		}
            		
            		
            		
            		
            		String gid = details[0];	//标识一个盘口的
            		gid = gid.replace("'", "");
            		
            		String datetime = details[1];
            		datetime = datetime.replace("'", "");
            		datetime = datetime.replace("<br>", " ");
            		
            		if(datetime.contains("半场")){
            			datetime = "半场";
            		}
            		
            		
            		
            		
            		String league = details[2];
            		league = league.replace("'", "");
            		
            		if(league.contains("-附加赛")) {
            			league = league.replace("-附加赛", "");
            		}
            		
            		
            		if(league.contains("特别投注")){            			
            			bignore = true;
            		}
            		
            		
            		
            		
            		String gnumh = details[3];
            		gnumh = gnumh.replace("'", "");
            		
            		String gnumc = details[4];
            		gnumc = gnumc.replace("'", "");
            		
            		
            		
            		
            		
            		String teamh = details[5];
            		teamh = teamh.replace("'", "");
            		teamh = teamh.replace(" [中]", "");

            		
            		if(teamh.contains("角球数")||teamh.contains("罚牌数")){
            			
            			bignore = true;
            		}
            		
            		
            		String teamc = details[6];
            		teamc = teamc.replace("'", "");
            		
            		
            		//全场
            		String strong = details[7];
            		strong = strong.replace("'", "");
            		
            		
            		
            		String pankou = details[8];
            		pankou = pankou.replace("'", "");
            		
            		
            		String rh = details[9];
            		rh = rh.replace("'", "");
            		
            		
            		String rc = details[10];
            		rc = rc.replace("'", "");
            		
            		
            		String o = details[11];
            		o = o.replace("'", "");
            		
            		
            		
            		String u = details[12];
            		u = u.replace("'", "");
            		
            		
            		String oh = details[13]; //小球赔率
            		oh = oh.replace("'", "");
            		
            		
            		String oc = details[14];//大球赔率
            		oc = oc.replace("'", "");
            		
            		

            		
            		
            		//半场	start index  20
            		
            		String hgid = details[20];
            		hgid = hgid.replace("'", "");
            		
            		String hstrong = details[21];
            		hstrong = hstrong.replace("'", "");
            		
            		
            		
            		
            		String hpankou = details[22];
            		hpankou = hpankou.replace("'", "");
            		
            		
            		
            		
            		String hrh = details[23];		//主队赔率
            		hrh = hrh.replace("'", "");
            		
            		
            		String hrc = details[24];	//客队赔率
            		hrc = hrc.replace("'", "");
            		
            		
            		String ho = details[25];
            		ho = ho.replace("'", "");
            		
            		
            		String hu = details[26];
            		hu = hu.replace("'", "");
            		
            		
            		
            		String hoh = details[27];	//小球赔率
            		hoh = hoh.replace("'", "");
            		
            		
            		String hoc = details[28];	//大球赔率
            		hoc = hoc.replace("'", "");
            		
            		
            		if(pankou.equals("") && hpankou.equals("") &&
            			o.equals("") && ho.equals("")){
            			bignore = true;
            		}
            		
            		if(bignore == false){

            			
            			HGEvent hgEvent = new HGEvent();
            			
            			hgEvent.eventId = eventid;
            			hgEvent.gid = gid;
            			hgEvent.leagueName = league;
            			hgEvent.homeTeam = teamh;
            			hgEvent.awayTeam = teamc;
            			hgEvent.homeTeamScore = scoreh;
            			hgEvent.awayTeamScore = scorec;
            			hgEvent.eventTime = datetime;
            			hgEvent.duringTime = timer;
            			hgEvent.gnumh = gnumh;
            			hgEvent.gnumc = gnumc;
            			hgEvent.wholeRQPPankou = Common.pankouStr(strong + pankou);
            			hgEvent.strong = strong;
            			hgEvent.hstrong = hstrong;
            			hgEvent.wholeRQPPankouUp = rh;
            			hgEvent.wholeRQPPankouDown = rc;
            			hgEvent.wholeDXPPankou = Common.pankouStr(o);
            			hgEvent.wholeDXPPankouUp = oc;
            			hgEvent.wholeDXPPankouDown = oh;
            			hgEvent.hgid = hgid;
            			hgEvent.halfRQPPankou = Common.pankouStr(hstrong + hpankou);
            			hgEvent.halfRQPPankouUp = hrh;
            			hgEvent.halfRQPPankouDown = hrc;
            			hgEvent.halfDXPPankou = Common.pankouStr(ho);
            			hgEvent.halfDXPPankouUp= hoc;
            			hgEvent.halfDXPPankouDown = hoh;
            			
            			HGEvents.add(hgEvent);

            		}


            		//下一场
            		ps = res.indexOf("g([", pe);
            		
            		if(ps == -1){
            			
            			
            			break;
            		}
            		
            		ps = ps +3;
            		
                	pe = res.indexOf(";", ps);
            		
            		previousgame = currentgame;
            		
            		
            	}
            	
            	
            	
            	
            	
            	ps = res.indexOf("t_page");
            	ps = res.indexOf("=", ps) + 1;
            	pe = res.indexOf(";", ps);
            	
            	int totalpage = Integer.parseInt(res.substring(ps, pe));
            	

            	
            	
            }
            
            
            
            
            
            
            return HGEvents;
    		
    	}catch(Exception e){
    		e.printStackTrace();
    		
    		updateStatusCode(3);
    		
    		addFailsTimes();
    		return null;
    	}
    	


    	
    	
    	
    	
    

}	
	
	
	
	
	
	
	
	
	/*
	 * 
	 */
	public Map<String, String> updateRatio(String gid, String type, String gnum, String strong, String rtype, String wtype) {

		String res = "";
		
		try {
			
			String url = "";
			
			if(strong.equals("")) {
			
				url = ADDRESS + "app/member/FT_order/FT_order_all.php?gid=" + gid + "&uid=" + user_id + "&odd_f_type=M&type=" + type + 
						"&gnum=" + gnum +  "&langx=zh-cn&ptype=&imp=N&rtype=" + rtype + "&wtype=" + wtype;
				
			}else {
				url = ADDRESS + "app/member/FT_order/FT_order_all.php?gid=" + gid + "&uid=" + user_id + "&odd_f_type=M&type=" + type + 
						"&gnum=" + gnum + "&strong=" + strong + "&langx=zh-cn&ptype=&imp=N&rtype=" + rtype + "&wtype=" + wtype;
			}
			
			
			res = doGet(url, "", "");
	    	
	    	Map<String, String> map=new HashMap<String, String>();
	    	
	    	
	    	if(res.contains("dafa008")) {
	    		
	    		System.out.println("Enter dafa");
	    		
	    		res = doGet(url, "", "");
	    	}
	    	
	    	
	    	if(res == null){
	    		res = doGet(url, "", "");
	    	}
	    	
	    	if(res.contains("è")){
        		res = new  String(res.getBytes("ISO-8859-1"), "utf-8");
        	}
	    	
	    	
			
	    	if(res.contains("确定交易")) {
	    		
	    		Document doc = Jsoup.parse(res);
	    		
	    		String divID = "model_" + wtype;
	    		
	            Element div = doc.getElementById(divID);
	            

	            String pankou = div.getElementsByClass("fatWord").first().html();
	            
	            if(pankou.equals("")) {
	            	pankou = div.getElementsByClass("fatWord").last().html();
	            	
	            	pankou = Double.toString(0.0-Common.pankouDouble(pankou));
	            	
	            }else {
	            	pankou = Double.toString(Common.pankouDouble(pankou));
	            }

	            String ratio = div.getElementsByClass("redFatWord").first().html();
	           
	            
	            map.put("pankou", pankou);
	            map.put("ratio", ratio);
	            
	            div = doc.getElementsByClass("ord_TotalAreaG").first();
	            
	            String minbet = div.getElementsByClass("Word_Toright").first().html();
	            String maxbet = div.getElementsByClass("Word_Toright").last().html();
	            
	            map.put("minbet", minbet);
	            map.put("maxbet", maxbet);
	            

	            
	            
	            //bet needed
	            
	            String autoOdd = doc.selectFirst("input[name=autoOdd]").val(); 
	            
	            String uid = doc.selectFirst("input[name=uid]").val();
	            String langx = doc.selectFirst("input[name=langx]").val();
	            String active = doc.selectFirst("input[name=active]").val();
	            String line_type = doc.selectFirst("input[name=line_type]").val();
	            String gid1 = doc.selectFirst("input[name=gid]").val();
	            String type1 = doc.selectFirst("input[name=type]").val();
	            String gnum1 = doc.selectFirst("input[name=gnum]").val();
	            String concede = doc.selectFirst("input[name=concede]").val();
	            String radio = doc.selectFirst("input[name=radio]").val();
	            String ioradio = doc.selectFirst("input[name=ioradio]").val();
	            String gmax_single = doc.selectFirst("input[name=gmax_single]").val();
	            String gmin_single = doc.selectFirst("input[name=gmin_single]").val();
	            String singlecredit = doc.selectFirst("input[name=singlecredit]").val();
	            String singleorder = doc.selectFirst("input[name=singleorder]").val();
	            String restsinglecredit = doc.selectFirst("input[name=restsinglecredit]").val();
	            String wagerstotal = doc.selectFirst("input[name=wagerstotal]").val();
	            String restcredit = doc.selectFirst("input[name=restcredit]").val();
	            String pay_type = doc.selectFirst("input[name=pay_type]").val();
	            String odd_f_type = doc.selectFirst("input[name=odd_f_type]").val();
	            String wtype1 = doc.selectFirst("input[name=wtype]").val();
	            String rtype1 = doc.selectFirst("input[name=rtype]").val();
	            String gametype = doc.selectFirst("input[name=gametype]").val();
	            String imp = doc.selectFirst("input[name=imp]").val();
	            String ptype = doc.selectFirst("input[name=ptype]").val();
	            String timestamp2 = doc.selectFirst("input[name=timestamp2]").val();
	    		
	    		gametype = URLEncoder.encode(gametype, "UTF-8");
	    		
		        String betParam = "&autoOdd=Y&uid=" + uid +"&langx=zh-cn&active=" + active +"&line_type="+ line_type +"&gid=" + gid1 + "&type=" + type1 +"&gnum="+ gnum1 +"&concede=" + concede + "&radio=" + radio +"&ioradio=" + ioradio + "&gmax_single="+ gmax_single+"&gmin_single=" + gmin_single + "&singlecredit="+ singlecredit +"&singleorder=" + singleorder +
		        						"&restsinglecredit="+ restsinglecredit +"&wagerstotal="+ wagerstotal +"&restcredit="+restcredit+"&pay_type="+pay_type+"&odd_f_type="+odd_f_type+"&wtype="+ wtype1 +"&rtype="+rtype1+"&gametype="+gametype+"&=10&imp=N&ptype=&timestamp2="+ timestamp2 +"&timestamp=" + Long.toString(System.currentTimeMillis());
	            
	            map.put("betParam", betParam);

	            return map;
	    	}
	    	
	    	
	    	System.out.println("更新  HG Ratio失败" + res);
	    	
	    	
	    	
	    	return null;
	    	
			
		}catch(Exception e) {
			e.printStackTrace();
			
			System.out.println("更新  PS38 Ratio失败" + res);
		}
		
		return null;
	}

    
	
	public  Map<String,String> doBet(String betParam, int gold){
		
		String res = "";
		
		Map<String,String> resmap = new HashMap<String, String>();
		
		try {


		        
	        String beturi = ADDRESS + "app/member/FT_order/FT_order_all.php?" + "gold="+ Integer.toString(gold) + betParam;


	       res = doGet(beturi, "", ADDRESS+ "/app/member/order.php?uid=" + user_id +"&langx=zh-cn&mtype=" + mtype + "&league_id=");
	        
	        
	        if(res.contains("è")){
        		res = new  String(res.getBytes("ISO-8859-1"), "utf-8");
        	}
    		
    		
	        
	        SimpleDateFormat dfSec = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	        
	        
	        int posSt = betParam.indexOf("wtype") + 6;
	        int posEnd  = betParam.indexOf("&", posSt);
	        
	        String wtype = betParam.substring(posSt, posEnd);
	        
	        
	        if(res.contains("bet_msg")) {
	        	
	        	
	        	
	        	String timel = dfSec.format(System.currentTimeMillis());
	        	
	        	
	        	Document doc = Jsoup.parse(res);
	    		String divID = "model_" + wtype;
	            Element div = doc.getElementById(divID);
	            
	            
	            String pankou = div.getElementsByClass("fatWord").first().html();
	            
	            if(pankou.equals("")) {
	            	pankou = div.getElementsByClass("fatWord").last().html();
	            	
	            	pankou = Double.toString(0.0-Common.pankouDouble(pankou));
	            	
	            }else {
	            	pankou = Double.toString(Common.pankouDouble(pankou));
	            }

	            String ratio = div.getElementsByClass("redFatWord").first().html();
	           
	            
	            String betteam = div.getElementsByClass("no_margin").first().html().split("@")[0];
	            
	            if(betteam.contains("<tt>小")) {
	            	betteam = "小";
	            }
	            
	            if(betteam.contains("<tt>大")) {
	            	betteam = "大";
	            }
	            
	            resmap.put("betteam", betteam);
	            resmap.put("betpankou", pankou);
	            resmap.put("betratio", ratio);
	            


	            String ticketid = doc.getElementsByClass("ord_betSucc_TB").first().getElementsByClass("Word_Paddright").last().html();
	            
	            resmap.put("ticketid", ticketid);
	            
	            String betMsg = doc.getElementById("bet_msg").html();
	            
	            
	           
	            
	            resmap.put("bettime", timel);
	            
	            if(betMsg.contains("下注成功")) {
	            	resmap.put("status", "1");
	            	
	            	DecreaseRatioClient.betCtrMng.lastbetsuccesstime = System.currentTimeMillis();
	            	
	            	
	            	return resmap;
	            }
	            
	            if(betMsg.contains("注单待确认")) {
	            	resmap.put("status", "0");
	            	
	            	DecreaseRatioClient.betCtrMng.lastbetsuccesstime = System.currentTimeMillis();
	            	return resmap;
	            }
	            
	            
	            
	            
	        }
	        
	        
	        
	        
	        
		       
	    		
	    	
			
		}catch(Exception e) {
			e.printStackTrace();
		}
		
		
		if(res.contains("超过信用余额")) {
			resmap.put("status", "-1");
        	return resmap;
		}
		
		
		if(res.contains("不可大于股东单场总信用额度")) {
			resmap.put("status", "-4");
			return resmap;
		}
		
		
		resmap.put("status", "-2");
        
        System.out.println("投注失败:" + res);
        
        return resmap;
		
	}
	
	
	




	
	
	
	
	
	
	
	public String getShowTodayRecURL(){
		
		
		
		//http://hga030.com/app/member/account/today_wagers.php?uid=qg3w277xom20694187l274422&langx=zh-cn&type=today_wagers
    		
		return ADDRESS + "app/member/account/today_wagers.php?uid=" + user_id + "&langx=zh-cn&type=today_wagers";
		
    		//String[] res = {ADDRESS + "app/member/account/get_today_wagers.php", "uid=" + user_id +"&langx=zh-cn&chk_cw=N&page=1"};
    		
    		//return res;
    		

    }
	
    public String getHistoryRecURL(){
    	
    	
    	try{

    		
    		//return oldSiteAddress + "app/member/history/history_data.php?uid="+ user_id +"&langx=zh-cn";

    		//http://hga030.com/app/member/account/history_data.php?uid=r4hzv9dnpm20834322l243950&langx=zh-cn&type=history_data
    		
    		return  ADDRESS + "app/member/account/history_data.php?uid=" + user_id + "&langx=zh-cn&type=history_data";
    		
    	}catch(Exception e){
    		e.printStackTrace();

    	}
    	
    	return "";
    }
    
    
    public void reloadCredit() {
    	
    }

	public void updatehgBetLogData(Vector<BetAdyData> betLogDatas) {
		// TODO Auto-generated method stub
		
		try {
			
			
			String url = ADDRESS + "app/member/get_order_mybet.php";
			
			
			List<NameValuePair> params = new ArrayList<NameValuePair>();		  
	        
	        params.add(new BasicNameValuePair("uid", user_id));
	        params.add(new BasicNameValuePair("langx", "zh-cn"));
	        params.add(new BasicNameValuePair("pgType", "10rec"));
	      
	        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
			
			
			String res = doPost(url, params, "");
			
			if(res == null) {
				res = doPost(url, params, "");
			}
			
			int ps = -1;
			int pe = -1;
			
			if(res != null && res.contains("betinfo")) {
				
				
				if(res.contains("è")){
	        		res = new  String(res.getBytes("ISO-8859-1"), "utf-8");
	        	}
				
				
				for(BetAdyData bd: betLogDatas) {
					
					if(bd.hgbetres.equals("0")) {
						String ticketid = bd.ticketid;
						
						ticketid = ticketid.replace("OU", "");
						
						ps = res.indexOf(ticketid);
						
						if(-1 == ps) {
							bd.hgbetres = "-1";
							continue;
						}
						
						ps = res.indexOf("betinfo", ps);
						ps = res.indexOf(">",ps) + 1;
						pe = res.indexOf("<", ps);
						
						String betres = res.substring(ps,pe);
						
						if(betres.equals("确认")) {
							bd.hgbetres = "2";
							
							System.out.println(df.format(System.currentTimeMillis()) + "  皇冠2比赛确认:   " + bd.teams + "   " + bd.ticketid);
							
							//System.out.println("betres= " + betres);
							
							//System.out.println("res = "  + res);
							
							
						}else if(betres.contains("待确认")) {
							continue;
						}else if(betres.contains("投注失败")) {
							bd.hgbetres = "-3";
							
							
							
						}
						
					}
					

					
				}
				
				
				
				
				
				
			}
			
			
		}catch(Exception e) {
			e.printStackTrace();
		}
		

		
		
		
	}
	
	
	
	public void checkIllealBet() {
		

		try {
			

			SimpleDateFormat df = new SimpleDateFormat("MM-dd HH:mm:ss");// 设置日期格式
			
			String uri = ADDRESS + "app/member/account/get_today_wagers.php";
			
			
			List<NameValuePair> params = new ArrayList<NameValuePair>();		  
	        
	        params.add(new BasicNameValuePair("uid", user_id));
	        params.add(new BasicNameValuePair("langx", "zh-cn"));
	        params.add(new BasicNameValuePair("chk_cw", "N"));
	        params.add(new BasicNameValuePair("page", "1"));
			
			String res = doPost(uri, params, "");
			
			if(res == null) {
				res = doPost(uri, params, "");
			}
			
			if(res == null) {
				return;
			}
			
			
			
			if(res != null && res.contains("è")){
	    		res = new  String(res.getBytes("ISO-8859-1"), "utf-8");
	    	}
			
			int page = 0;
			
			if(res.contains("total_page")) {
				int ps = res.indexOf("total_page");
				ps = res.indexOf(">",ps)+1;
				int pe = res.indexOf("<",ps);
				
				page = Integer.parseInt(res.substring(ps, pe));
				
				if(res.contains("非正常投注")) {
					System.out.println(df.format(System.currentTimeMillis()) + "特殊存在非投，停止投注");					
					DecreaseRatioClient.hasSpecialIllegalBet = true;
					return;
				}
			}
			
			Thread.sleep(500);
			
			
			for(int i = 2; i <= page; i++) {
				
				List<NameValuePair> params1 = new ArrayList<NameValuePair>();		  
		        
		        params1.add(new BasicNameValuePair("uid", user_id));
		        params1.add(new BasicNameValuePair("langx", "zh-cn"));
		        params1.add(new BasicNameValuePair("chk_cw", "N"));
		        params.add(new BasicNameValuePair("page", Integer.toString(i)));
				
				res = doPost(uri, params1, "");
				
				Thread.sleep(500);
				
				if(res != null && res.contains("è")){
		    		res = new  String(res.getBytes("ISO-8859-1"), "utf-8");
		    	}
				
				if(res!= null && res.contains("非正常投注")) {
					
					System.out.println(df.format(System.currentTimeMillis()) + "特殊存在非投，停止投注");
					
					DecreaseRatioClient.hasSpecialIllegalBet = true;
					return;
				}
			}
		}catch(Exception e) {
			e.printStackTrace();
		}
	}

	public void setCookie() {
		
		Browser.setCookie("OddType@21916632=H", "http://hga030.com/");
		Browser.setCookie("gamePoint_21916632=2019-07-23%2A0%2A0", "http://hga030.com/");
	}
	
	
    

}
